package org.opens.config;

import freemarker.template.TemplateModelException;
import org.opens.template.DirectiveHandler;
import org.opens.template.SidebarDirective;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;

@Configuration
public class FreemarkerConfig {

    @Autowired
    private freemarker.template.Configuration configuration;

    @Autowired
    private SidebarDirective directiveHandler;

    // 将自定义的标签注册到freemarker的全局变量中去
    @PostConstruct
    public void setSharedVariable() throws TemplateModelException {
        configuration.setSharedVariable(directiveHandler.getName(), directiveHandler);
    }


}
